<template>
  <div>
    <div class="search">
      <van-search
        background="transparent"
        disabled
        show-action
        placeholder="请输入小区或地址"
      >
        <template #label>
          <span class="home-search" @click="$router.push('/city')">
            {{ city.label }}<van-icon name="play" class="home-search-icon" />
          </span>
          <span class="home-search-rigth-border"></span>
        </template>
        <template #action>
          <div>
            <div class="maps" @click="$router.push('/map')">
              <i class="iconfont icon-map"></i>
            </div>
          </div>
        </template>
      </van-search>
    </div>
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="#999">
      <van-swipe-item
        v-for="item in swiper"
        :key="item.id"
        :style="{
          backgroundImage: 'url(http://liufusong.top:8080' + item.imgSrc + ')',
        }"
      ></van-swipe-item>
      <!-- <van-swipe-item
        style="
          background-image: url(http://liufusong.top:8080/img/swiper/2.png);
        "
      ></van-swipe-item>
      <van-swipe-item
        style="
          background-image: url(http://liufusong.top:8080/img/swiper/3.png);
        "
      ></van-swipe-item> -->
    </van-swipe>
    <van-grid :border="false" :column-num="4">
      <van-grid-item to="/search">
        <van-image
          width="60px"
          src=""
        />
        <span class="vanVridText">整租</span>
      </van-grid-item>
      <van-grid-item to="/search">
        <van-image
          width="60px"
          src=""
        />
        <span class="vanVridText">合租</span>
      </van-grid-item>
      <van-grid-item to="/map">
        <van-image
          width="60px"
          src=""
        />
        <span class="vanVridText">地图找房</span>
      </van-grid-item>
      <van-grid-item to="/add">
        <van-image
          width="60px"
          src=""
        />
        <span class="vanVridText">去出租</span>
      </van-grid-item>
    </van-grid>
    <div class="teams">
      <div class="head">
        <div class="title">找房小组</div>
        <div class="more">更多</div>
      </div>
      <van-grid
        direction="horizontal"
        :column-num="2"
        :border="false"
        :gutter="10"
      >
        <van-grid-item v-for="item in groups" :key="item.id">
          <van-image :src="'http://liufusong.top:8080' + item.imgSrc" />
          <div>
            <p>{{ item.title }}</p>
            <p>{{ item.desc }}</p>
          </div>
        </van-grid-item>
        <!-- <van-grid-item>
    <van-image src="http://liufusong.top:8080/img/groups/2.png" />
    <div>
      <p>宜居四五环</p>
      <p>大都市生活</p>
    </div>
  </van-grid-item>
  <van-grid-item>
    <van-image src="http://liufusong.top:8080/img/groups/3.png" />
    <div>
      <p>喧嚣三里屯</p>
      <p>繁华的背后</p>
      {{swiper}}
    </div>
  </van-grid-item>
  <van-grid-item>
    <van-image src="http://liufusong.top:8080/img/groups/4.png" />
    <div>
      <p>比邻十号线</p>
      <p>地铁心连心</p>
    </div>
  </van-grid-item> -->
      </van-grid>
    </div>
  </div>
</template>

<script>
import '@/icon/iconfont.css'
import { getSwiper, getGroups } from '@/api/homo'
import { getCity } from '@/utils/storage'
export default {
  data () {
    return {
      swiper: [],
      groups: [],
      city: ''
    }
  },
  async created () {
    const { body: swiper } = await getSwiper()
    this.swiper = swiper
    const city = getCity()
    this.city = city
    const { body: groups } = await getGroups(city.value)
    this.groups = groups
  }
}
</script>

<style lang="less">
.home-search-rigth-border {
  height: 20px;
  margin: 0 7px 0 12px;
  border-right: 1px solid #999;
}
.home-search-icon {
  transform: rotate(0.25turn);
  color: #999;
}
.teams {
  background-color: #f6f5f6;
  // padding: 0 10px 10px 10px;
  padding-bottom: 10px;
  .head {
    padding: 15px 10px 15px 25px;
    font-size: 15px;
    display: flex;
    justify-content: space-between;
    .title {
      font-weight: 700;
    }
    .more {
      color: #666;
      font-size: 13px;
    }
  }
  .van-grid-item__content {
    justify-content: flex-start !important;
    img {
      height: 50px;
      width: 50px;
    }
    div {
      margin-left: 8px;
    }
  }
}
.vanVridText {
  margin-top: 12px;
  font-size: 14px;
}
.search {
  position: absolute;
  z-index: 1;
  width: 375px;
}
// .my-swipe.van-swipe{
//   position: absolute;
//   z-index: -1;
//   top:0;
//   width: 375px;
//   height: 212px;
// }
.my-swipe .van-swipe-item {
  background-color: @blue;
  background-size: 100% 100%;
  // width: 100%;
  // height: 100%;
  width: 375px;
  height: 212px;
}
.maps {
  color: #fff;
  i {
    font-size: 34px;
    line-height: 63.5px;
  }
}
</style>
